package com.videoshare.user;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.commons.logging.*;
import java.util.*;

public class UserLoginForm extends ActionForm 
{
	private static Log log = LogFactory.getLog(UserLoginForm.class);
	
	private String userName;
	private String password;
	private String profile;
	private String email;
	private boolean loggedIn;
	
	/**
	 * @return Returns the password.
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password The password to set.
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return Returns the userName.
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param userName The userName to set.
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	/**
	 * @return Returns the profile.
	 */
	public String getProfile() {
		return profile;
	}
	/**
	 * @param profile The profile to set.
	 */
	public void setProfile(String profile) {
		this.profile = profile;
	}
	
	/**
	 * @return Returns the email.
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email The email to set.
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return Returns the loggedIn.
	 */
	public boolean isLoggedIn() {
		return loggedIn;
	}
	/**
	 * @param loggedIn The loggedIn to set.
	 */
	public void setLoggedIn(boolean loggedIn) {
		this.loggedIn = loggedIn;
	}
	
	
	public void reset(ActionMapping mapping, HttpServletRequest request)
	{
		
		userName = null;
		password = null;
		profile = null;
		email = null;
		loggedIn = false;
		
		log.trace("reset");
	}
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
	{
		ActionErrors errors = new ActionErrors();
		
		
		
		if( (userName == null) || userName.trim().equals(""))
		{
			errors.add("userName", new ActionMessage("userRegistration.userName.problem"));
		}
		if( (password == null) || password.trim().equals(""))
		{
			errors.add("password", new ActionMessage("userRegistration.password.problem"));
		}
		
		log.trace("validate");
		
		return errors;
	}


}
